﻿<Window x:Class="Demos.Hashmap.View"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Hashmap" Height="350" Width="500">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition></RowDefinition>
        </Grid.RowDefinitions>
        
        <Menu Grid.Row="0">
            <MenuItem Header="Opciones">
                <MenuItem Header="Insertar palabra" Command="{Binding ComenzarInsercionCommand}"></MenuItem>
                <MenuItem Header="Ver Hashmap" Command="{Binding VerHashMapCommand}"></MenuItem>
                <MenuItem Header="Salir" Click="Salir_Click"></MenuItem>
            </MenuItem>
        </Menu>

        <StackPanel Grid.Row="1" Orientation="Horizontal"  HorizontalAlignment="Left" Margin="10,5,0,0">
            <Button Width="100" Command="{Binding CerrarPestañasCommand}">Cerrar pestañas</Button>
        </StackPanel>
        <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,5,10,0">
            <TextBox Width="120" Foreground="Gray" Name="buscarTXT" GotFocus="buscarTXT_GotFocus"
                     Text="{Binding PalabraBuscada, UpdateSourceTrigger=PropertyChanged}">
            </TextBox>
            <Button Margin="5,0,0,0" Width="50" Name="buscarBTN" IsDefault="True"
                    Command="{Binding BuscarPalabraCommand}">Buscar</Button>
        </StackPanel>
        
        <TabControl Grid.Row="2" Name="definicionesTC" Margin="10" 
                    ItemsSource="{Binding Palabras}"
                    SelectedIndex="{Binding PestañaSeleccionada, UpdateSourceTrigger=PropertyChanged}">
            <TabControl.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Nombre}" />
                </DataTemplate>
            </TabControl.ItemTemplate>
            <TabControl.ContentTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Vertical">
                        <Label FontSize="16" FontWeight="Bold"
                               Content="{Binding Nombre, UpdateSourceTrigger=PropertyChanged}">
                        </Label>
                        <Label FontSize="12" FontWeight="Normal" Foreground="Red"
                               Content="{Binding Origen, UpdateSourceTrigger=PropertyChanged}">
                        </Label>
                        <Label FontSize="12" FontWeight="Normal" Foreground="Black"
                               Content="{Binding Definiciones, UpdateSourceTrigger=PropertyChanged}">
                        </Label>
                    </StackPanel>
                </DataTemplate>
            </TabControl.ContentTemplate>
        </TabControl>
        
        <Grid Grid.Row="1" Grid.RowSpan="2" Name="insertarPalabraGD" 
              Visibility="{Binding VerInsercion, UpdateSourceTrigger=PropertyChanged}" Background="Snow">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="Auto"></RowDefinition>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"></ColumnDefinition>
                <ColumnDefinition></ColumnDefinition>
            </Grid.ColumnDefinitions>

            <Label Grid.Row="0" Grid.Column="0" Margin="10,10,0,0">Palabra:</Label>
            <TextBox Grid.Row="0" Grid.Column="1" Width="120" Margin="0,10,10,0" 
                     HorizontalAlignment="Left" Name="palabraTXT"
                     Text="{Binding NuevaPalabraNombre, UpdateSourceTrigger=PropertyChanged}">
            </TextBox>

            <Label Grid.Row="1" Grid.Column="0" Margin="10,10,0,0">Origen:</Label>
            <TextBox Grid.Row="1" Grid.Column="1" Width="200" Margin="0,10,10,0" 
                     HorizontalAlignment="Left" Name="origenTXT"
                     Text="{Binding NuevaPalabraOrigen, UpdateSourceTrigger=PropertyChanged}">
            </TextBox>

            <Label Grid.Row="2" Grid.Column="0" Margin="10,10,0,0">Definiciones:</Label>
            <ScrollViewer Grid.Row="2" Grid.Column="1" Margin="0,10,10,0" Height="170"  VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Hidden">
                <ItemsControl ItemsSource="{Binding NuevaPalabraDefiniciones}" BorderBrush="Transparent">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Vertical"></StackPanel>
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <TextBox Height="50" AcceptsReturn="True" Text="{Binding Texto}" Margin="0,5,0,0"></TextBox>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </ScrollViewer>

            <Button Grid.Row="3" Grid.Column="0" Width="100" Margin="10,10,0,0"
                    Command="{Binding AñadirMasDefinicionesCommand}">Más definiciones</Button>
            <StackPanel Grid.Row="3" Grid.Column="1" Margin="0,10,10,0" HorizontalAlignment="Right" Orientation="Horizontal">
                <Button Width="100" Margin="0,0,5,0"
                        Command="{Binding CancelarCommand}">Cancelar</Button>
                <Button Width="100"
                        Command="{Binding InsertarCommand}">Insertar</Button>
            </StackPanel>
        </Grid>
    </Grid>
</Window>
